package com.quanshu.exchange.ui.gui.message.chat.redpackage;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.quanshu.exchange.R;
import com.quanshu.exchange.support.utils.RxViewHelper;
import com.quanshu.exchange.ui.base.BaseActivity;

import butterknife.BindView;
import butterknife.ButterKnife;

public class RedPackageTypeActivity extends BaseActivity {

    @BindView(R.id.back)
    LinearLayout back;
    @BindView(R.id.lucky_red_package_btn)
    ImageView luckyRedPackageBtn;
    @BindView(R.id.normal_red_package_btn)
    ImageView normalRedPackageBtn;

    private String sumMembers;
    private String destId;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_create_red_package_type);
        ButterKnife.bind(this);
        initIntent();
        initListener();
    }

    private void initIntent() {
        sumMembers = getIntent().getStringExtra("sumMembers");
        destId = getIntent().getStringExtra("destId");
    }

    private void initListener() {

        RxViewHelper.getInstance().clicks(back, aVoid -> finish());
        RxViewHelper.getInstance().clicks(luckyRedPackageBtn, aVoid -> doClickLucky());
        RxViewHelper.getInstance().clicks(normalRedPackageBtn, aVoid -> doClickNormal());

    }

    private void doClickNormal() {

        Intent intent = new Intent(this, NormalRedPackageActivity.class);
        intent.putExtra("sumMembers", sumMembers);
        intent.putExtra("destId", destId);
        startActivityForResult(intent, 0x01);
    }

    private void doClickLucky() {

        Intent intent = new Intent(this, LuckyRedPackageActivity.class);
        intent.putExtra("sumMembers", sumMembers);
        intent.putExtra("destId", destId);
        startActivityForResult(intent, 0x01);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == RESULT_OK) {
            if (requestCode == 0x01) {
                setResult(RESULT_OK, data);
                finish();
            }
        }

    }
}
